<!DOCTYPE html>  
<meta charset="utf-8" />  
<title>测试WebSocket</title>  

<div id="output"></div>  
<script language="javascript"type="text/javascript">  
    // var wsUri ="ws://wsc.wlo.wxfenxiao.com:6868/wlimr/ws/wl?from_uid=885"; 
    var wsUri ="ws://127.0.0.1:6060/pipes/ws/chat"; 
    var output;  
	var websocket;
    
    function init() { 
        output = document.getElementById("output"); 
        testWebSocket(); 
    }  
 
    function testWebSocket() { 
        websocket = new WebSocket(wsUri); 
        //console.log(websocket);
        
        websocket.onopen = function(evt) { 
            onOpen(evt) 
        }; 
        
        websocket.onclose = function(evt) { 
            onClose(evt) 
        }; 
        
        websocket.onmessage = function(evt) { 
            onMessage(evt) 
        }; 
        
        websocket.onerror = function(evt) { 
            onError(evt) 
        }; 
        
    }  
	
    function onOpen(evt) { 
    	//document.write("<br> WS打开了: "+ evt);
    }  
 
    function onClose(evt) { 
    	//document.write("<br> WS关闭了: "+ evt);
    }  
 
    function onMessage(evt) { 
        //document.write("<br> WS消息: "+ evt);
    }  
 
    function onError(evt) { 
    	//document.write("<br> WS出错了: "+ JSON.stringify(evt));
    }  
 
    init();

	function send(){  //32753
		var  msg = "aaaa";
		for(var i=0;i<20240;i++){  //102400
			msg +="1234567890"
		}
		msg +="bbbb";

		    websocket.send(JSON.stringify({
           sendmessage:{
               message:{
                   content : msg
               },
               extmap:{
                   "a":1,
                   "b":"haha"
               }
           }
      }));
	}
</script>  
<h2>WebSocket Test</h2>  
<button onclick="send()" value="发送">发送</button>
</html>